//跳动的文本，用于战果显示
//用法：使文本跳动

var jpTInst = null;
// using #NUM0,#NUM1,#NUM2... to instead of numbers, tickTime is millisecond
var JumpingText = function(label,textPattern,numbersOrigin,numbersDivide,tickNum,tickTime){
	this.label = label;
	this.tickNum = tickNum;
	this.tickTime = tickTime;
	this.textPattern = textPattern;
	this.numbers = numbersOrigin;
	this.numbersDivide = numbersDivide;

	jpTInst = this;

	this.timeOutHandle = null;

	this.Start = function(){
		if (jpTInst.label != null && jpTInst.tickNum > 0){
			var text = jpTInst.textPattern;

			for (var i = 0; i < jpTInst.numbers.length; i++){
				jpTInst.numbers[i] += jpTInst.numbersDivide[i];
				text = StringReplace(text, "#NUM" + i, "" + Math.round(jpTInst.numbers[i]));
			}
			jpTInst.label.setString(text);
			
			jpTInst.tickNum--;
			jpTInst.timeOutHandle = setTimeout(jpTInst.Start, jpTInst.tickTime * 1000);
		}
	};

	this.Stop = function(){
		if (jpTInst.timeOutHandle != null){
			clearTimeout(jpTInst.timeOutHandle);
			jpTInst.timeOutHandle = null;
		}
	}

	this.Terminate = function(){
		jpTInst.tickNum = 0;
	};
};